{extend name="platform/base"}
{block name="resources"}
<style>
.hint{white-space:nowrap;}
</style>
{/block}
{block name="main"}
 <section class="panel panel-default">
	<!-- <header class="panel-heading font-bold"> 添加主题 </header> -->
	<div class="panel-body">
		<form class="form-horizontal" id="subjectSetting_form" name="form">
			<div class="form-group">
				<label class="col-sm-2 control-label"><span class="color-red">*</span>投诉时效</label>
				<div class="col-md-2">
					<input type="number" min="0" max="9999" onkeydown="error_hide()" class="form-control" id="subjectSetting_name" name="subjectSetting_name" required value="{$val}" onkeydown="error_hide()">
       			<br/><a class="hint" style="color:#BBB;">单位为天，订单完成后开始计算，多少天内可以发起投诉</a>
			</div>
         	<p class="error">投诉失效必须是数字并不能为空</p>
			</div>
			<div class="form-group">
				<div class="col-sm-4 col-sm-offset-2">
					<!-- <button type="submit" class="btn btn-primary">保存<tton> -->
					<a href="javascript:void(0);" onclick="addReportTypeAjax()" class="btn btn-primary">保存</a> 
				</div>
			</div>
		</form>
	</div>
</section> 
{/block}
{block name="script"}
<script>
	// $().ready(function() {
 //    LoadingInfo();
	// 	$("#subjectSetting_form").validate({
	// 		submitHandler : function() {
	// 			addReportTypeAjax();
	// 		}
	// 	});
 //  });
  /*加载数据*/
  // function LoadingInfo(){
  //   $.ajax({
  //     type : "POST",
  //     url : "PLATFORM_MAIN/complain/getComplainSetting",
  //     async : true,
  //     success : function(data){
  //       $("#subjectSetting_name").val(data);
  //     }
  //   });
  // }
  function error_hide(){
  	$(".error").hide();
  	$(".hint").show();
  }
	/**
	 *添加模块
	 */
		function addReportTypeAjax() {
			var subjectSetting_name = $("#subjectSetting_name").val();
			if(subjectSetting_name == 0 || subjectSetting_name == ''){
				$("#subjectSetting_name").focus().parent().next().show();
				return false;
			}else{
				$(".error").hide();
			}
		$.ajax({
			type : "post",
			url : "{:__URL('PLATFORM_MAIN/complain/complainSetting')}",
			data : {
				'subjectSetting_name' : subjectSetting_name,

			},
			async : true,
			success : function(data) {
 				console.log(123);
				if (data['code'] > 0) {
					showMessage('success', data["message"],'{:__URL("PLATFORM_MAIN/complain/complainsetting")}');
				} else {
					showMessage('error', data["message"]);
				}
			}
		});
	}

</script>
{/block}